<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>访问器属性</title>
</head>
<body>
<script>
    let user = {
        fullName: 'Alice'
    }


    let jack = {
        __proto__: user
    }

    console.log(jack.fullName)

    /*
    * 这里的写操作只会在自己身上执行
    * */
    jack.fullName = 'Jack'
    console.log(jack.fullName)
    console.log(user.fullName)


    let animal = {
        _name: 'Alice',
        set name(name) {
            this._name = name
        },

        get name() {
            return this._name
        }
    }

    let dog = {
        __proto__: animal
    }

    /*
    * 由于name属性是访问器属性 所以dog.name会访问到父类,而不会在自己身上直接定义
    *  在访问父类时  this._name = name 这里的this是子类  所以会在自己身上定义一个_name和访问器name
    *
    * */
    dog.name = 'fheui'
    console.log(dog.name)
    console.log(animal.name)
    console.log(dog)

</script>
</body>
</html>